<?php

class Campo_model extends CI_Model {

	public function __construct(){
		parent::__construct();
	}
 
	
	function make_link($url = null, $string, $id = null){
		
		$link = 'erro';
	
		switch ($string){

			case 'adicionar':
				$link = '<a class="btn btn-default" href="'.$url.'" role="button"><i class="fa fa-plus fa-lg"></i> Adicionar</a>';
			break;
			
			case 'voltar':
				$link = '<a href="javascript: window.history.go(-1)" class="btn btn-default btn-sm"><i class="fa fa-reply fa-lg"></i> Voltar</a>';
			break;
			
			case 'cancelar':
				$link = '<a href="javascript: window.history.go(-1)" class="btn btn-default"><i class="fa fa-reply fa-lg"></i> Cancelar</a>';
			break;
			
			case 'salvar':
				$link = '<button type="submit" class="btn btn-success"><i class="fa fa-check fa-lg"></i> Salvar</button>';
			break;
			
			case 'alterar':
				$link = '<a class="btn btn-primary btn-sm" href="'.$url.'" role="button"><i class="fa fa-pencil fa-lg"></i> Alterar</a>';
			break;
			
			case 'deletar':
				$link = '<a class="btn btn-danger  btn-sm" href="'.$url.'" role="button" onclick="return confirm(\'Deseja REALMENTE cancelar esse registro?\')"><i class="fa fa-trash fa-lg"></i> Excluir</a>';
			break;
			
			case 'publicar':
				$link = '<a class="btn btn-default btn-sm" href="'.$url.'" role="button"><i class="fa fa-close fa-lg"></i> Não publicada</a>';
			break;
			
			case 'despublicar':
				$link = '<a class="btn btn-success btn-sm" href="'.$url.'" role="button"><i class="fa fa-check fa-lg"></i> Publicada</a>';
			break;
		
		}
	
		return $link;
	
	}

//--- Fim do botoes ---//

//--- Campos dos formularios ---//

	function usuario($indice) {
		$campo = array(
		 
				'campoNome' => array(
						'type'		=> 'text',
						'name' 		=> 'campoNome',
						'id' 		=> 'campoNome',
						'value'		=> mb_convert_case($this->input->post('campoNome'), MB_CASE_UPPER, "ISO-8859-1"),
						'class' 	=> 'form-control text-uppercase',
						'required' 	=> 'required'
				),
			
				'campoEmail' => array(
						'type' 		=> 'email',
						'name' 		=> 'campoEmail',
						'id'		=> 'campoEmail',
						'value' 	=> mb_convert_case($this->input->post('campoEmail'), MB_CASE_LOWER, "ISO-8859-1"),
						'class' 	=> 'form-control text-lowercase',
						'required' 	=> 'required'
				),
				 
				'campoSenha' => array(
						'type' 		=> 'password',
						'name' 		=> 'campoSenha',
						'id' 		=> 'campoSenha',
						'value' 	=> $this->input->post('campoSenha'),
						'class' 	=> 'form-control',
						'required' 	=> 'required'
				),
				 
				'campoConfSenha' => array(
						'type' 		=> 'password',
						'name' 		=> 'campoConfSenha',
						'id' 		=> 'campoConfSenha',
						'value' 	=> $this->input->post('campoConfSenha'),
						'class' 	=> 'form-control',
						'required' 	=> 'required'
				),
				 
				'campoNivel' => array(
						'name' 		=> 'campoNivel',
						'id' 		=> 'campoNivel',
						'value' 	=> mb_convert_case($this->input->post('campoNivel'), MB_CASE_UPPER, "ISO-8859-1"),
						'maxlength' => '2',
						'size' 		=> '2',
						'class' 	=> 'form-control text-uppercase',
				),
				 
				'arrayNiveis' => array(
						'1'  => 'ADMINISTRADOR',
						'2'  => 'REDATOR',
				),
	
		);
	
		return $campo[$indice];
	}
    
	
	function noticia($indice) {
		$campo = array(
					
				'campoTitulo' => array(
						'type'		=> 'text',
						'name' 		=> 'campoTitulo',
						'id' 		=> 'campoTitulo',
						'value'		=> $this->input->post('campoTitulo'),
						'class' 	=> 'form-control',
						'maxlength' 	=> '100',
						'required' 	=> 'required'
				),
					
				'campoData' => array(
						'type' 		=> 'text',
						'name' 		=> 'campoData',
						'id'		=> 'campoData',
						'value' 	=> $this->input->post('campoData'),
						'class' 	=> 'form-control',
						'required' 	=> 'required'
				),
					
				'campoRedacao' => array(
						'type' 		=> 'text',
						'name' 		=> 'campoRedacao',
						'id' 		=> 'campoRedacao',
						'value' 	=> $this->input->post('campoRedacao'),
						'class' 	=> 'form-control',
						'required' 	=> 'required'
				),
	
		);
	
		return $campo[$indice];
	}


}

?>